package com.sws.web.controller.ry_rongyue.push;

import java.util.List;

import com.sws.common.utils.poi.ExcelUtil;
import com.sws.push.domain.AiModelConfig;
import com.sws.push.service.IAiModelConfigService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sws.common.annotation.Log;
import com.sws.common.core.controller.BaseController;
import com.sws.common.core.domain.AjaxResult;
import com.sws.common.enums.BusinessType;
import com.sws.common.core.page.TableDataInfo;

/**
 * AI模型管理Controller
 * 
 * @author ruoyi
 * @date 2025-07-04
 */
@RestController
@RequestMapping("/ry/aiModel/aiModel")
public class AiModelConfigController extends BaseController
{
    @Autowired
    private IAiModelConfigService aiModelConfigService;

    /**
     * 查询AI模型管理列表
     */
    @PreAuthorize("@ss.hasPermi('aiModel:aiModel:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiModelConfig aiModelConfig)
    {
        startPage();
        List<AiModelConfig> list = aiModelConfigService.selectAiModelConfigList(aiModelConfig);
        return getDataTable(list);
    }

    /**
     * 导出AI模型管理列表
     */
    @PreAuthorize("@ss.hasPermi('aiModel:aiModel:export')")
    @Log(title = "AI模型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiModelConfig aiModelConfig)
    {
        List<AiModelConfig> list = aiModelConfigService.selectAiModelConfigList(aiModelConfig);
        ExcelUtil<AiModelConfig> util = new ExcelUtil<AiModelConfig>(AiModelConfig.class);
        util.exportExcel(response, list, "AI模型管理数据");
    }

    /**
     * 获取AI模型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('aiModel:aiModel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiModelConfigService.selectAiModelConfigById(id));
    }

    /**
     * 新增AI模型管理
     */
    @PreAuthorize("@ss.hasPermi('aiModel:aiModel:add')")
    @Log(title = "AI模型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiModelConfig aiModelConfig)
    {
        return toAjax(aiModelConfigService.insertAiModelConfig(aiModelConfig));
    }

    /**
     * 修改AI模型管理
     */
    @PreAuthorize("@ss.hasPermi('aiModel:aiModel:edit')")
    @Log(title = "AI模型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiModelConfig aiModelConfig)
    {
        return toAjax(aiModelConfigService.updateAiModelConfig(aiModelConfig));
    }

    /**
     * 删除AI模型管理
     */
    @PreAuthorize("@ss.hasPermi('aiModel:aiModel:remove')")
    @Log(title = "AI模型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiModelConfigService.deleteAiModelConfigByIds(ids));
    }
}
